<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增页面</title>
    <style type="text/css">
        td{
            height: 25px;
            width: 100px;
            border: #3a8ee6 1px solid;

        }
        input{
            height: 21px;
        }
    </style>

    <script type="text/javascript" src="../../js/jquery-3.3.1.js"></script>
    <script type="text/javascript" src="../../js/01/daoru/finddiName.js"></script>
    <script type="text/javascript">
        $(function(){

            //查询所有药品类别
            $.ajax({
                url:"/myspringboot/DrugCategoryController/fandAllDrugCategory",
                data:"",
                type:"post",
                dataType:"json",
                success:function(result){
                    console.log(result);
                    var result = result.data;
                    var opts = "";
                    for (var i = 0; i < result.length; i++) {
                        var dcId = result[i].dcId;
                        var dcName = result[i].dcName;
                        var opt = '<option value="'+dcId+'">'+dcName+'</option>';
                        opts += opt;
                    }
                    $("#b").append(opts);
                }
            })

        })


    </script>
    <script type="text/javascript">
        function  add() {
            //药品品目添加
            //获取到所有的参数
            var daNumber = $("#daNumber").val();
            var diName = $("#diName").val();
            var diForm = $("#diForm").val();
            var diSpecifications = $("#diSpecifications").val();
            var diUnit = $("#diUnit").val();
            var diCc = $("#diCc").val();
            var diDaCategory = $(".diDaCategory").val();
            var diState = $("#diState").val();
            $.ajax({
                url: '/myspringboot/DrugAtegoryController/fandAllDrugAtegory',
                type: 'POST',
                dataType: "json",
                data:{
                    daNumber:daNumber,//前面参数对应的实体类，后面对应上面的var参数
                    diName:diName,
                    diForm:diForm,
                    diSpecifications:diSpecifications,
                    diUnit:diUnit,
                    diCc:diCc,
                    diDaCategory:diDaCategory,
                    diState:diState
                },
                success:function (result) {
                    alert(result.msg)
                    window.location.href="drug01.html"
                }
            })
        }
    </script>

</head>
<body>
<table class="" style="border: 1px solid #999;border-collapse:collapse">
    <tr>
        药品品目查询
    </tr>
    <tr>
        <td>药品品目号：</td>
        <td><input type="text" value="" id="daNumber"></td>
        <td></td>
        <td>通用名：</td>
        <td><input type="text" value="" class="ddName" onblur="finddiName()"></td>
        <td></td>
    </tr>
    <tr>
        <td>剂型：</td>
        <td><input type="text" value="" id="diForm"></td>
        <td></td>
        <td>规格：</td>
        <td><input type="text" value="" id="diSpecifications"></td>
        <td></td>
    </tr>
    <tr>
        <td>单位：</td>
        <td><input type="text" value="" id="diUnit"></td>
        <td></td>
        <td>转换系数：</td>
        <td><input type="text" value="" id="diCc"></td>
        <td></td>
    </tr>
    <tr>
        <td>药品类别：</td>
        <td>
            <select style=" height: 25px; width: 160px;" id="b" class="diDaCategory">
                <option value="">请选择</option>
            </select>
        </td>
        <td></td>
        <td>状态：</td>
        <td>
            <select style=" height: 25px; width: 160px;" id="diState">
                <option value="">请选择</option>
                <option value="0">正常</option>
                <option value="1">异常</option>
            </select>
        </td>
        <td></td>
    </tr>
</table>
<td>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <button onclick="add()">提交</button>
    <button onclick="history.go(-1)" href="javascript:if(confirm('确实要放弃操作吗?返回之后，所添加数据不会保存！'))location='add.html'">
        关闭
    </button>
</td>
</body>
</html>